package com.itheima.studentmanager.mapper;

import com.itheima.studentmanager.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * The interface Student mapper.
 */
@Mapper
public interface StudentMapper {


    /**
     * Username exist integer.
     *
     * @param username the username
     * @return the integer
     */
    @Select("select * from student where username = #{username};")
    Integer usernameExist(String username);

    /**
     * Register.
     *
     * @param student the student
     */
    @Insert("insert into student (username, age, gender, password) values (#{username},#{age},#{gender},#{password});")
    void register(Student student);


    /**
     * Delete student by id.
     *
     * @param i the
     */
    @Delete("delete from student where id = #{id};")
    void deleteStudentById(int i);

    /**
     * Find all student list.
     *
     * @return the list
     */
    @Select("select * from student;")
    List<Student> findAllStudent();


    /**
     * Gets student by id.
     *
     * @param id the id
     * @return the student by id
     */
    @Select("select * from student where id = #{id};")
    Student getStudentById(Integer id);

    /**
     * Gets id exists.
     *
     * @return the id exists
     */
    @Select("select * from student where id = #{id};")
    Integer getIdExists();

    /**
     * Update student.
     *
     * @param student the student
     */
    @Update("update student set username = #{username},age = #{age}, gender = #{gender} where id = #{id}")
    void updateStudent(Student student);

    /**
     * Delete batch student.
     *
     * @param ids the ids
     */
    void deleteBatchStudent(List<Integer> ids);
}
